<!DOCTYPE html>
<html>
<head>
    <title>修改医生--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
    $(function () {       
		$('#backid').click(function(){
				window.location.href="index.html";
		 });
    });
    </script>
</head>
<body>
<form id="updateForm" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft" >姓名</td>
        <td >
            <input  name="dName" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">身份证号</td>
        <td >
            <input name="dIdcar" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">手机</td>
        <td >
            <input name="dPhone" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">座机</td>
        <td >
            <input name="dTelphone" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td >
            <input type="radio" name="dSex" value="0" checked/>男&nbsp;&nbsp;&nbsp;
            <input type="radio" name="dSex" value="1"/>女
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td >
            <input name="dAge" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">出生年月</td>
        <td >
            <input type="date" name="dBirthday" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">入职时间</td>
        <td >
            <input type="date" name="dIntime" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">电子邮箱</td>
        <td >
            <input name="dEmail" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">所属科室</td>
        <td >
            <input name="dKeshi" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">学历</td>
        <td >
            <input name="dXueli" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">职业状态</td>
        <td >
            <input type="radio" name="dState" value="0" checked/>在职&nbsp;&nbsp;&nbsp;
            <input type="radio" name="dState" value="1"/>离职
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">备注</td>
        <td >
            <input name="dDesc" placeholder="test" />
        </td>
    </tr>
    <tr>
        <td colspan="2">
			<center>
				<button id="updateDoctor" class="btn btn-primary" type="button">更新</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
</html>
<script type="text/javascript">
    $(function () {
        //根据地址获取doctorId,如果null则执行增加，否则执行更新
        let url = document.location.toString();//获取URL
        let doctorId = url.GetValue("doctorId");
        let pageNum = url.GetValue("pageNum");
        let pageSize = url.GetValue("pageSize");
        //根据id回显医生信息到页面
        queryById(doctorId);
        //更新
        $("#updateDoctor").click(function (){
            $.post("/hospital/doctor/"+doctorId,$("#updateForm").serialize()+"&_method=PUT",function (vo){
                if (vo.code == 200){
                    window.location.href = "/doctor/index.html?pagaNum="+pageNum+"&pageSize="+pageSize;
                }else {
                    alert("更新失败！"+vo.msg);
                }
            },"json");
        });



    });
    //回显函数
    function queryById(doctorId) {
        $.get("/hospital/doctor/"+doctorId, {} ,function (vo){
            let obj = vo.obj;
            let dId = obj.dId;
            let dName = obj.dName;
            let dIdcar = obj.dIdcar;
            let dPhone = obj.dPhone;
            let dTelphone = obj.dTelphone;
            let dSex = obj.dSex;
            let dBirthday = obj.dBirthday;
            let dAge = obj.dAge;
            let dEmail = obj.dEmail;
            let dKeshi = obj.dKeshi;
            let dXueli = obj.dXueli;
            let dDesc = obj.dDesc;
            let dIntime = obj.dIntime;
            let dState = obj.dState;

            $("input[name='dName']").val(dName);
            $("input[name='dIdcar']").val(dIdcar);
            $("input[name='dPhone']").val(dPhone);
            $("input[name='dTelphone']").val(dTelphone);
            $("input[name='dBirthday']").val(dBirthday);
            $("input[name='dAge']").val(dAge);
            $("input[name='dEmail']").val(dEmail);
            $("input[name='dKeshi']").val(dKeshi);
            $("input[name='dXueli']").val(dXueli);
            $("input[name='dDesc']").val(dDesc);
            $("input[name='dIntime']").val(dIntime);
            if (dSex){
                $("input[name='dSex'][value='1']").attr("checked",true);
            }else {
                $("input[name='dSex'][value='0']").attr("checked",true);
            }
            if (dState){
                $("input[name='dState'][value='1']").attr("checked",true);
            }else{
                $("input[name='dState'][value='0']").attr("checked",true);
            }


        });
    }
    String.prototype.GetValue = function (para) {
        let reg = new RegExp("(^|&)" + para + "=([^&]*)(&|$)");
        let r = this.substr(this.indexOf("\?") + 1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }
</script>